package com.zzg.common.base.helper;

import java.util.Map;
import java.util.stream.Collector;
import java.util.stream.Collectors;

public class Pair<K, V> {

    private K first = null;
    private V second = null;

    protected Pair(K k, V v) {
        this.first = k;
        this.second = v;
    }

    public K getFirst() {
        return first;
    }

    public V getSecond() {
        return second;
    }

    public static <F, S> Pair<F, S> create(F f, S s) {
        return new Pair<F, S>(f, s);
    }

    public static <K, U> Collector<? super Pair<K, U>, ?, Map<K, U>> toMap() {
        return Collectors.toMap(p -> p.getFirst(), p -> p.getSecond());
    }
}
